package seqlist.leetcode;

public class Num876 {
    public ListNode middleNode(ListNode head) {
//       int count=0;
//       for (ListNode x=head;x!=null;x=x.next){
//           count++;
//       }
//       ListNode middle=head;
//       int middleindex=count/2;
//        for (int i = 0; i < middleindex; i++) {
//                    middle=middle.next;
//        }
//        return middle;
        ListNode fast = head;
        ListNode low =head;
        while (fast!=null&&fast.next!=null){
            fast = fast.next.next;
            low=low.next;
        }
        return low;
    }
}
